package controller

import (
	"net/http"
	"strconv"
	"text/template"

	"gitee.com/shuwenhe/shuwen/deleteItemByID/dao"
)

func GetItems(w http.ResponseWriter, r *http.Request) {
	items, _ := dao.GetItems()
	t := template.Must(template.ParseFiles("view/page/manager/item_manager.html"))
	t.Execute(w, items)
}

func DeleteItemByID(w http.ResponseWriter, r *http.Request) {
	itemID := r.FormValue("itemID")
	id, _ := strconv.Atoi(itemID)
	dao.DeleteItemByID(id)
	GetItems(w, r)
}
